package com.autism.day03;

public class Computer {
    public void powerOn() {
        System.out.println("电脑开机！");
    }

    public void powerOff() {
        System.out.println("电脑关机！");
    }

    //使用接口作为参数
    public void useDevice(USB usb) {
        usb.open();
        if (usb instanceof Mouse) {
            //向下转型
            Mouse mouse = (Mouse) usb;
            mouse.click();
        } else if (usb instanceof KeyBoard) {
            //向下转型
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.type();
        }
        usb.close();
    }
}
